package ylsb.service;


import org.springframework.stereotype.Service;
import ylsb.dao.ShebeiMapper;
import ylsb.model.Shebei;
import ylsb.model.ShebeiExample;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ShebeiService {

    @Resource
    ShebeiMapper ddMapper;

    public List<Map<String, Object>> findBiaojuelist(String mmxiangmuId, String mmuserId){
        return ddMapper.findBiaojuelist(mmxiangmuId,mmuserId);
    }
    public boolean isexistByxiangmuId(String xiangmuId){
        ShebeiExample mmExample=new ShebeiExample();
        ShebeiExample.Criteria criteria=mmExample.createCriteria();
        criteria.andXiangmuidEqualTo(xiangmuId);
        return  ddMapper.selectByExample(mmExample).size()>0;
    }
    public boolean add (Shebei ddShebei){
        return ddMapper.insert(ddShebei)==1;
    }
    public boolean deleteByxiangmuId(String xiangmuId){
        ShebeiExample mmExample=new ShebeiExample();
        ShebeiExample.Criteria criteria=mmExample.createCriteria();
        criteria.andXiangmuidEqualTo(xiangmuId);
        return  ddMapper.deleteByExample(mmExample)>=0;
    }
    public List<Shebei> findlist(String xiangmuId){
        ShebeiExample mmExample=new ShebeiExample();
        mmExample.createCriteria().andXiangmuidEqualTo(xiangmuId);
        mmExample.setOrderByClause("ordernumber ASC");
        return  ddMapper.selectByExample(mmExample);
    }
    public Integer getShebeiCount(String ppXiangmuId) {
        Object mmCount = ddMapper.countShebeiByXiangmuId(ppXiangmuId);
        return mmCount == null ? 0 : Integer.parseInt(mmCount.toString());
    }

}
